/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {void} Do not return anything, modify head in-place instead.
 */
 var reorderList = function(head) {
    if(head==null || head.next==null){
        return head;
    }
    let arr=[];
    while(head!=null){
        arr.push(head);
        head=head.next;
    }
    let j=arr.length-1;
    let i=0;
    while(i<j){
        arr[i].next = arr[j];
            i++;
            if (i == j) {
                break;
            }
            arr[j].next = arr[i];
            j--;

        }
        arr[i].next=null;
    return arr[0];
};